/**
 * 税务辅导
 * @author 程文智
 */
package com.taxsystem.chengwenzhi.tax_assistant;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.SimpleAdapter;

import com.main.taxsystem.ListAndSearchActivity;
import com.main.taxsystem.R;

public class TaxAssistantActivity extends Activity {

	private static final String TAG ="TaxAssistantActivity";
	private GridView container = null;
	private static final String EVENTS[] = new String[]{"税务登记","发票管理","申报征收",
		"文书备案","开具证明","减税退税","各种税率","房地产交易政策","操作指引"};
	private ArrayList<HashMap<String,Object>> list = null;
	private SimpleAdapter adapter = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.v(TAG,"onCreate():start");
		setContentView(R.layout.grid_view_layout_cwz);
		
		ActionBar bar = getActionBar();
        bar.setHomeButtonEnabled(true);
        bar.setIcon(R.drawable.actionbar_icon);
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setBackgroundDrawable(new ColorDrawable(0xff34a4f7));
        
		
		container = (GridView) this.findViewById(R.id.gridView);
		
		initList();
		
		adapter = new SimpleAdapter(this,list,R.layout.grid_item,
				new String[]{"icon","title"},new int[]{R.id.image_item,R.id.text_item});
		
		container.setAdapter(adapter);
		container.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position,
					long id) {
				Intent intent = new Intent(TaxAssistantActivity.this,ListAndSearchActivity.class);
				intent.putExtra("title", EVENTS[position]);
				startActivity(intent);
				
			}
			
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		return true;
	}
	
	void initList(){
		list = new ArrayList<HashMap<String,Object>>();
		for(String str : EVENTS){
			HashMap<String,Object> map = new HashMap<String,Object>();
			map.put("title",str);
			map.put("icon", R.drawable.temp_logo);
			list.add(map);
		}
	}
}
